package com.utils;

import java.util.Map;

public class APIRespones {
    private boolean status;
    private Map<String, Object> data;
    private String error;

    public APIRespones(boolean status, Map<String, Object> data, String error) {
        this.status = status;
        this.data = data;
        this.error = error;
    }
//get方法
    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    // 成功响应的工厂方法
    public static APIRespones success(Map<String, Object> keyValues) {
        return new APIRespones(true, keyValues, null);
    }


    // 失败响应的工厂方法
    public static APIRespones failure(String errorMessage) {
        return new APIRespones(false, null, errorMessage);
    }
}